package sshstudy.host.action;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.ResultPath;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import sshstudy.common.action.BaseAction;
import sshstudy.host.model.Host;
import sshstudy.host.service.ABCService;
import sshstudy.host.service.HostService;

@Component
@Namespace("/host")
@ResultPath(value="/")
public final class HostListAction extends BaseAction {

	private static final long serialVersionUID = 1L;
	
	private List<Host> hosts;
	
	@Autowired
	private HostService hostService;
	
	@Autowired
	private ABCService abcService;
	
	@Action(value="list",
		results={@Result(name="success", location="list.jsp")}
	)
	@Override
	public String execute() throws Exception {
		hosts = hostService.list();
		abcService.test();
		return SUCCESS;
	}

	public List<Host> getHosts() {
		return hosts;
	}

	public void setHosts(List<Host> hosts) {
		this.hosts = hosts;
	}
	
	public HostService getHostService() {
		return hostService;
	}

	public void setHostService(HostService hostService) {
		this.hostService = hostService;
	}
}
